<?php
// +----------------------------------------------------------------------
// | Jqcms [ Avenue to Jane ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://jqcms.net All rights reserved.
// +----------------------------------------------------------------------
// | Author: hyacinth <845077398@qq.com>
// +----------------------------------------------------------------------
namespace Admin\Model;
use Think\Model;

class NavModel extends Model{
    
    //验证
    protected $_validate = array(
    
        array('name','require','栏目名不能为空!'),      
    
    );
    //获取导航分类
    public function getNavcate(){
        
        $list = $this->order(array('pid'=>'asc'))->select();
        $data = list_to_tree($list,'id','pid');
        return $data;
        
    }
    //获取文章分类
    public function getArtcate(){
        
        $cate = M('Category');
        $data = $cate->order('sort desc')->select();
        return $data;
        
    }
    //获取单页
    public function getPage(){
        
        $page = M('Page');
        $data = $page->order('id desc')->select();
        return $data;
        
    }
    //获取设置模块
    public function getBlock($block,$cid){
        
        switch ($block){
            case 1:
                $cate = M('Category');
                $data = $cate->find($cid);
                break;
            case 2:
                $page = M('Page');
                $data = $page->find($cid);
                break;
        }
        return $data;
        
    }
    
    
    
    
}